<template>
  <div class="ranking">
    <div class="ranking-header">
      <img src="../assets/ranking-header.jpg" alt="">
      <button>返回</button>
      <div class="tab">
        <div @click="clickMoneyList" :class="[isActive ? 'activate': 'un-activate']"  class="money">
           <span>奖金榜</span>
        </div>
        <div @click="clickPromotionList" :class="[isActive ? 'un-activate': 'activate']"  class="spread">
          <span>推广榜</span>
        </div>
      </div>
    </div>
    <div class="ranking-content-top">
      <span>排行</span>
      <span>用户</span>
      <span v-if="isActive">奖金数</span>
      <span v-if="!isActive">扫码人数</span>
    </div>
    <ul class="ranking-content">
      <li v-for="item in items">
        <span v-if="item.rank>3">{{ item.rank }}</span>
        <img v-if="item.rank===1" src="../assets/gold-medal.png" alt="">
        <img v-if="item.rank===2" src="../assets/silver-medal.png" alt="">
        <img v-if="item.rank===3" src="../assets/copper-medal.png" alt="">
        <span>{{ item.name }}</span>
        <span>{{ item.person }}</span>
      </li>
    </ul>
    <div class="ranking-footer">
      <img src="../assets/ranking-footer.png" alt="">
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        isActive: false,
        items: [
          { name: 'ZhangSan', rank: 1, person: 1000 },
          { name: 'LiSi', rank: 2, person: 900 },
          { name: 'WangWU', rank: 3, person: 800 },
          { name: 'LaoLiu', rank: 4, person: 700 },
          { name: 'LaoLiu', rank: 4, person: 700 },
          { name: 'LaoLiu', rank: 4, person: 700 },
          { name: 'LaoLiu', rank: 4, person: 700 },
          { name: 'HeiQi', rank: 5, person: 600 }
        ]
      };
    },
    methods: {
      clickMoneyList() {
        this.isActive = true;
      },
      clickPromotionList() {
        this.isActive = false;
      }
    }
  };
</script>
<style scoped>
  ul, li {
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .ranking-header{
    font-size: 0;
    height: auto;
    position: relative;
    width: 100%;
  }
  .ranking-header img{
    padding: 0;
    margin: 0;
    border: none;
    width: 100%;
  }
  .ranking-header button{
    position: absolute;
    height: 0.45rem;
    width: 1.57rem;
    border-radius: 0.2rem;
    right: 0.2rem;
    top: 0.2rem;
    color: #ffffff;
    font-size: 0.28rem;
    background-color: #000000;
    opacity: 0.4;
    outline: none;
    border-width:0;
   }
  .tab {
    position: absolute;
    bottom: 0;
    left: calc(50% - 2.5rem);
    font-size: 0.34rem;
  }
  .spread,.money {
    float: left;
    height: 0.8rem;
    line-height: 0.8rem;
    text-align: center;
    width: 2.5rem;
    border-top-left-radius: 1.2em;
    border-top-right-radius: 1.2em;
  }

  .un-activate {
    color: #5bB6e5;
    background-color: #ffffff;
  }
  .activate {
    color: #ffffff;
    background-image:linear-gradient(to right,#3BC7DD,#578DE4);
  }
  .ranking-content-top {
    position: relative;
    line-height: 0.9rem;
    height: 0.9rem;
    margin: 0 auto;
    color: #ffffff;
    font-size: 0.36rem;
    background-image:linear-gradient(to right,#578DE4,#3BC7DD);
  }
  .ranking-content-top span:nth-child(1) {
    position: absolute;
    left: 12%;
  }
  .ranking-content-top span:nth-child(2) {
    position: absolute;
    left: 42%;
  }
  .ranking-content-top span:nth-child(3) {
    position: absolute;
    left: 70%;
  }
  .ranking-content li {
    display: flex;
    align-items: center;
    line-height: 1;
    height: 1.4rem;
    border-bottom: 1px solid #c0c0c0;
  }
  .ranking-content {
    position: relative;
    height: 7rem;
    overflow:scroll;
  }
  .ranking-content li span{
    line-height: 1.4rem;
    font-size: 0.28rem;
    color: #282828;
  }
  .ranking-content li img{
    height: 0.7rem;
    width: 0.5rem;
    position: absolute;
    left: 12%;
  }
  .ranking-content li span:nth-child(1) {
    position: absolute;
    left: 14%;
  }
  .ranking-content li span:nth-child(2) {
    position: absolute;
    left: 40%;
  }
  .ranking-content li span:nth-child(3) {
    position: absolute;
    left: 73%;
  }
  .ranking-footer{
    font-size: 0;
    position: fixed;
    bottom: 0;
  }
  .ranking-footer img{
    width: 100%;
  }
</style>
